<?php
ob_start();
session_start();
include '../../operations/connection.php';

$iddept = $_REQUEST['iddeptment'];
$deptname = $_REQUEST['deptname'];
$locationdept = $_REQUEST['locationdept'];
$descriptiondept = $_REQUEST['descriptiondept'];

if (isset($_REQUEST['updatedept'])){
	$sqlupdate = "update department_lang set DepartmentName = '$deptname', Location = '$locationdept', Description = '$descriptiondept' 
				where IDDepartment = '$iddept' and LangID = '".$_SESSION['lang']."'";
	mysql_query($sqlupdate);
}else if (isset($_REQUEST['deletedept'])){
	$sqldelete = "DELETE dp,dl FROM department AS dp LEFT JOIN department_lang AS dl 
				ON dp.IDDepartment=dl.IDDepartment WHERE dp.IDDepartment = $iddept ";
	mysql_query($sqldelete);
}

mysql_close($connection);

if(isset($_REQUEST['updatedept'])){
	$_SESSION['alertupdate'] ="";
	header("Location: ../../deparment-admin.php");
}
if(isset($_REQUEST['deletedept'])){
	$_SESSION['alertdelete'] ="";
	header("Location: ../../deparment-admin.php");
}
?>